<?php
/**
 * 留言管理页面
 *
 * @author Alen
 * @since 1.0.0 2013-10-3 sutroon
 */
class Feedback_ListAction extends AdmincpAction {
    
    //put your code here
    public function index(){
        
        // 设置页面信息,如页面标题,meta信息等
        $this->set_page_info('留言管理');
        
        $biz=new SoBizFeedback();        
        $pager_text='';
        $dataset=null;
        $biz->get_paging_data($pager_text, $dataset, request_numeric('page'), request_string('keyword'));
        
        $this->assign('pager',$pager_text);
        
        // 构建数据表格
        $this->uig->begin_table();
        $this->uig->add_thead('#','摘要','内容','日期','状态','管理');
        
        if($dataset){
            $biz=new SoBizCommon(false);
            foreach($dataset as $row){
                $this->uig->add_trow($row['ID'],sprintf('标题:%s<br />用户名:%s<br />电子邮件:%s<br />电话:%s',$row['Title'],$row['UserName'],$row['Email'],$row['Mobilephone']),$row['Content'],$row['CreatedTime'],$biz->switch_state(array('v'=>$row['State'],'group'=>array('0'=>'未读','1'=>'已读'))),$this->get_control_linkbuttons($row['ID'],$row['Title'],'Feedback',array('delete') ));
            }
        }
        $this->uig->end_table();
        $this->assign('table',$this->uig->get_text());
        // 批量更新状态未已读
        
        if(!$this->dm) $this->dm=new SoDataModule();
        $this->dm->update_records('tgeneralfeedback', 'State=1', 'State=0');
        
        // 显示模板
        $this->display();
    }
    
    public function delete(){        
        $id=request_numeric('id');
        if($id){            
            $this->dm->delete_records('tgeneralfeedback','ID='.$id);
            redirect('删除成功','?m=Feedback_List');        
        }
    }
}

?>
